import React from "react";
import { Link } from "react-router-dom";
import { connect } from "react-redux";
import { homeActionTest } from "@/redux/actions/home";
class Home extends React.Component {
  constructor(props) {
    super(props);
    console.log(props);
  }
  render() {
    let { count, getSum } = this.props;

    return (
      <>
        <main>
          <h2>Welcome to the homepage!</h2>
          <p>You can do this, I believe in you.</p>
        </main>
        <nav>
          <Link to="/about">About</Link>
        </nav>
        <button onClick={getSum}>增加</button>
        {count}
      </>
    );
  }
}
function mapStateToProps(state) {
  console.log("mapStateToProps", state);
  return {
    count: state.home.count,
  };
}
function mapDispatchToProps(dispatch) {
  console.log("mapDispatchToProps");
  return {
    getSum: function () {
      return dispatch(homeActionTest({ type: "GETSUM", data: 1 }));
    },
  };
}
export default connect(mapStateToProps, mapDispatchToProps)(Home);
